<template>
  <div id="refDiv">
    <el-row :gutter="20">
      <el-col class="refItem" :span="8" :offset="0">
        服务费: {{ refundInfo.serviceFee }}元</el-col
      >
      <el-col class="refItem" :span="8" :offset="0">
        手续费: {{ refundInfo.refundFee }}元</el-col
      >
      <el-col class="refItem" :span="24" :offset="0">
        退款:
        <el-radio-group v-model="feeData.refundType" @change="radioRefMoney">
          <el-radio :label="1">全部退款</el-radio>
          <el-radio :label="2">退手续费</el-radio>
          <el-radio :label="3">退服务费</el-radio>
        </el-radio-group>
      </el-col>
      <el-col class="refItem" :span="24" :offset="0">
        退款金额:
        <span style="color: #ff7b48">{{ feeData.refundFee }}元</span></el-col
      >
      <el-col class="refItem" :span="24" :offset="0">
        退款原因:
        <el-input
          type="textarea"
          :rows="3"
          placeholder="请输入内容"
          v-model="feeData.refundReason"
        >
        </el-input
      ></el-col>
      <el-col :span="24" :offset="16" style="margin-top: 30px">
        <el-button @click="refSend(1)">取 消</el-button>
        <el-button type="primary" @click="refSend(2)">确 定</el-button>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import utils from "../../js/index";
export default {
  props: ["parentRefData"],
  data() {
    return {
      // 退手续费所需数据
      feeData: {
        orderCode: undefined,
        refundType: undefined,
        refundServiceFee: undefined,
        refundFee: 0,
        refundReason: undefined,
      },
    };
  },
  created() {
    console.log(this.parentRefData);
    this.refundInfo = this.parentRefData.refundInfo;
  },
  methods: {
    radioRefMoney(val) {
      switch (val) {
        case 1:
          this.feeData.refundFee =
            Number(this.refundInfo.serviceFee) +
            Number(this.refundInfo.refundFee);
          break;
        case 2:
          this.feeData.refundFee = Number(this.refundInfo.refundFee);
          break;
        case 3:
          this.feeData.refundFee = Number(this.refundInfo.serviceFee);
          break;

        default:
          break;
      }
    },

    refSend(n) {
      this.feeData.orderCode = this.parentRefData.orderInfo.orderCode;
      this.$emit("success", n, this.feeData);
    },
  },
};
</script>

<style scoped>
.refItem {
  line-height: 50px;
}
#refDiv {
  font-size: 15px;
}
</style>